<?php

namespace Ticket\Entity;

use Doctrine\ORM\Mapping as ORM;

/**
 *  @ORM\Entity(repositoryClass="\Ticket\Repository\TicketRepository")
 */
class Ticket {

    /**
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="AUTO")
     * @ORM\Column(type="integer")
     */
    protected $id;

    /**
     * @ORM\Column(type="string") 
     */
    protected $category;

    /**
     * @ORM\Column(type="string") 
     */
    protected $title;

    /**
     * @ORM\Column(type="string") 
     */
    protected $description;

    /**
     * @ORM\OneToMany(targetEntity="TicketUpdate", mappedBy="ticket") 
     * @ORM\OrderBy({"id" = "ASC"})
     */
    protected $updates;

    /**
     * @ORM\ManyToOne(targetEntity="\User\Entity\User")
     * @ORM\JoinColumn(name="user", referencedColumnName="id", nullable=false)
     * */
    protected $user;

    /**
     * @ORM\ManyToOne(targetEntity="\Client\Entity\Client")
     * @ORM\JoinColumn(name="client", referencedColumnName="id", nullable=false)
     * */
    protected $client;

    /**
     * @ORM\Column(type="datetime")
     */
    protected $time;

    /**
     * @ORM\Column(type="boolean")
     */
    protected $closed = false;
    
    public function __construct() {
        $this->updates = new \Doctrine\Common\Collections\ArrayCollection();
    }

    public function getId() {
        return $this->id;
    }

    public function getCategory() {
        return $this->category;
    }

    public function getTitle() {
        return $this->title;
    }

    public function getUser() {
        return $this->user;
    }

    public function getClient() {
        return $this->client;
    }

    public function getTime() {
        return $this->time;
    }

    public function setUpdates($updates) {
        $this->updates = $updates;
    }

    public function setUser($user) {
        $this->user = $user;
    }

    public function setClient($client) {
        $this->client = $client;
    }

    public function setTime($time) {
        $this->time = $time;
    }

    public function getDescription() {
        return $this->description;
    }

    public function getUpdates() {
        return $this->updates;
    }

    public function setId($id) {
        $this->id = $id;
    }

    public function setTitle($title) {
        $this->title = $title;
    }

    public function setCategory($category) {
        $this->category = $category;
    }

    public function setDescription($description) {
        $this->description = $description;
    }

    public function addUpdate(TicketUpdate $update) {
        $this->updates[] = $update;
        $update->setTicket($this);
    }
    public function getClosed() {
        return $this->closed;
    }

    public function setClosed($closed) {
        $this->closed = $closed;
    }


}